package com.seasky.solphire.storm.demo.utils;

import java.io.IOException;
import java.util.Properties;

/**
 * Created by RLY on 2019/2/1.
 */
public class ParamUtils {

    private static Properties conf = new Properties();

    static {
        try {
            conf.load(ParamUtils.class.getClassLoader().getResourceAsStream("solphire-storm.conf"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getString(String key) {
        return conf.getProperty(key);
    }

    public static int getInt(String key) {
        String value = getString(key);
        if (value != null) {
            return Integer.parseInt(value);
        }
        return -1;
    }

    public static void main(String[] args) {
        System.out.println("start...");
        String hostStr = ParamUtils.getString("zk.server");
        System.out.println("host = " + hostStr);
        int port = ParamUtils.getInt("zk.port");
        System.out.println("port = " + port);
    }
}
